display("conf[CBABILL_STATE]"); // 需要翻译的类型
$(function() {
    $('#cbabillEditDialog').dialog({
        buttons:[{text:'保存',handler:function(){
            if(!$('#cbabillEditForm').form('validate')){return;}
            $('#cbabillEditForm')._ajaxForm(function(r){
                if(r.r){
                	$('#cbabillEditDialog').dialog('close');
                	$('#grid').datagrid('reload');
                }else{
                	$.messager.alert('操作提示', r.m,'error');
                }
            });
        }},{text:'关闭',handler:function(){$('#cbabillEditDialog').dialog('close');}}]
    });
    var grid = $('#grid')._datagrid({
        checkOnSelect:false,
        selectOnCheck:false
    });
    $('#queryButton').click(function(){
        var params = $('#queryForm')._formToJson();
        $(grid).datagrid('load',params);
    });
});
var formatter = {
    state : function(value, rowData, rowIndex) {
    	//return value != null ? $.fn.display.conf.CBABILL_STATE[value]: "--";
        if(value == 1){ 
        	return '<font color=red>待处理</font>'; 
        }else if(value == 2){ 
        	return '<font color=red>被拒绝</font>'; 
        }else if(value == 3){ 
        	return '<font color=blue>处理中</font>'; 
        }else if(value == 4){ 
        	return '<font color=green>处理成功</font>'; 
        }else if(value == 5){ 
        	return '<font color=green>处理失败</font>'; 
        }else{
        	return '--';
        }
    },
    bsType : function(data, type, full){
        switch(data) {
        case 1:
          return "餐饮";
        case 2:
          return "生活缴费";
        case 3:
          return "个人转账";
        case 4:
            return "活动";
      	case 5:
            return "支付宝活动";
    	}
        return "";
      },
      payType : function(data, type, full){
        switch(data) {
        case 1:
          return "自动转账";
        case 2:
          return "手动转账";
        case 3:
          return "人工转账";
        }
        return "";
     },
     opt : function(value, rowData, rowIndex) {
        var html = '<a class="spacing a-blue" onclick="updCabBill('+rowIndex+');" href="javascript:void(0);">详情</a>';
        return html;
     }
};
/*详情*/
function updCabBill(rowIndex) {
    $('#cbabillEditForm').attr('action','tranfer/upd.html').resetForm();
    var data = $('#grid').datagrid('getRows')[rowIndex];
    data.txtbsType = formatter.bsType(data.bsType, 'edit', data);
    data.txtpayType = formatter.payType(data.payType, 'edit', data);
    data.txtstate = data.state != null ? $.fn.display.conf.CBABILL_STATE[data.state]: "--";
    data.txtdoneTime = data.doneTime;
    data.txtpaySchedu = data.paySchedu;
    $('#cbabillEditForm')._jsonToForm(data);
    $('#cbabillEditDialog').dialog('open').dialog('setTitle','转账日志详情');
}

/**导出*/
$(function() {
	$('#excelExport').click(function(){
		var lodgementRef = $("#lodgementRef").val();
		var bsId = $("#bsId").val();
	   	var businessName = $("#businessName").val();
	   	var state = $("#state").val();
	   	var timeType =$("#timeType").val();
	   	var timeFrom =$("#timeFrom").datebox('getValue'); 
	   	var timeEnd =$("#timeEnd").datebox('getValue');
	   document.location.href = "/tranferExport.html?lodgementRef=" + lodgementRef+"&bsId="+bsId+"&businessName="+businessName+"&state="+state+"&timeType="+timeType+"&timeFrom="+timeFrom+"&timeEnd="+timeEnd;
	});
});
